package model

type Counts struct {
	Count int `json:"count" form:"count" ` //总条数
}

//	"gorm.io/driver/mysql"
//	"gorm.io/gorm"

type ActivityStruct struct {
	//http://127.0.0.1:9900/v1/home/activity/detail?token=1111&username=abc&page=2
	ID    int    `json:"id"`                                                 //`资讯 ID`
	Title string `json:"title" form:"title" binding:"min=4,max=20,required"` //`资讯 标题`
	//reqdred=ID 不是和id内容是一样的。
	//omitempty 为空 或者大于0
	//dive 继承上一级的验证
	//	UserId int
	//UserName string
}
type ActivityData struct {
	ActivityStruct
	AddTime int64  `json:"addtime" form:"addtime" gorm:"Column:add_time"`
	Time    string `json:"time" form:"time" `
	Content string `json:"content" form:"content" binding:"required"` //`资讯内容
}

type ActivityQueryStruct struct {
	//	ID int `json:"id"` //`资讯 ID`
	//	Title string `json:"title"` //`资讯 标题`
	//http://127.0.0.1:9900/v1/home/activity/index?token=1111&username=abc&page=2
	ActivityStruct
	Page     int    `json:"page"  form:"page" binding:"required"` //binding强制绑定参数
	PageSize int    `json:"pagesize" form:"pagesize"`             //form 输出内容
	UserId   int    `json:"userid"  form:"userid"`
	UserName string `json:"username" form:"username"`
}

func ActivityDetail(id int, title string) ActivityStruct {

	return ActivityStruct{id, title}
}

func ActivityCreate(id int, title string) ActivityStruct {

	return ActivityStruct{id, title}
}

/*
//gorm 查询
func ActivityGormDetail(data ActivityData) ActivityData  {
	dsn := "root:root@tcp(127.0.0.1:3306)/txgo?charset=utf8mb4&parseTime=True&loc=Local"
	db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	db.Raw("SELECT * FROM users WHERE id = ?", 1).Scan(&ActivityData)
	return ActivityData

}
*/
